<template>
  <el-dialog
    append-to-body
    :close-on-click-modal="false"
    :before-close="crud.cancelCU"
    :visible="crud.status.cu > 0"
    :title="crud.status.title"
    width="500px"
  >
    <el-form
      label-width="100px"
      size="small"
      ref="form"
      :model="form"
      :rules="rules"
    >
      <el-form-item label="采购单位：" prop="name">
        <el-input v-model="form.name"/>
      </el-form-item>
      <el-form-item label="换算系数：" prop="coefficient">
        <el-input-number
          v-model="form.coefficient"
          :controls="false"
          :precision="0"
          :min="0"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button :loading="crud.procesLoading" type="primary" @click="crud.submitCU">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { form } from '@crud/crud';

const defaultForm = {
  name: null,
  coefficient: null
}

export default {
  name: "factorForm",
  mixins: [ form(defaultForm) ],
  data() {
    return {
      rules: {
        name: [
          { required: true, message: '请输入采购单位', trigger: 'blur' }
        ],
        coefficient: [
          { required: true, message: '请输入换算系数', trigger: 'blur' }
        ]
      }
    }
  }
}
</script>